<?php
	echo "<h2 id='contentTitle'>".$pageTitle."</h2>";
	echo $this->renderElement('message');

	if ($othAuth->hasPermission('assistidos/add/')) {
		
		$addButton = "<span class=\"buttonAdd\">Cadastrar assistido</span>";
		echo html_entity_decode($html->link($addButton, '/assistidos/add/',array('class'=>'button')));
	}
	
        
	if (isset($assistidos) && is_array($assistidos) && (!empty($assistidos))) {
		echo "<br />";
		echo "<table>";
		/* Cabeçalho */
		echo "<thead>";
		echo "<div></div>";
		echo "<tr class='tableHeader'>";
		echo "<th class='tableHeaderBegin'>Nome</th>";
		echo "<th class='tableHeaderMiddle'>Unidade</th>";
		if ($othAuth->hasPermission('assistidos/edit/')) {
			echo "<th class='tableHeaderMiddle'>Editar</th>";
		}
		if ($othAuth->hasPermission('assistidos/delete/')) {
			echo "<th class='tableHeaderEnd'>Excluir</th>";
		}
		echo "</tr>";
		echo "</thead>";
		
		/* Rodapé */
		echo "<tfoot>";
		echo "<tr class='tableFooter'>
		<td colspan='100%'></td>
		</tr>";
		echo "</tfoot>";
		
		/* Registros */
		$i=0;
		foreach ($assistidos as $assistido) {
			if (($i++ % 2) == 1) $zebrado = " class='oddTr' ";
			else $zebrado = "";
			echo "<tr ".$zebrado.">";
			echo "<td>".$html->link($assistido['Assistido']['nome'],'/assistidos/view/'.$assistido['Assistido']['id'])."</td>";
			echo "<td>".$html->link($assistido['Unit']['nome'],'/units/view/'.$assistido['Unit']['id'])."</td>";
			echo "<td class='tdCenter'>".html_entity_decode($html->link($html->image('fileedit.png',array('class'=>'icon')), '/assistidos/edit/'.$assistido['Assistido']['id']))."</td>";
			echo "<td class='tdCenter'>".html_entity_decode($html->link($html->image('filedel.png',array('class'=>'icon')), '/assistidos/delete/'.$assistido['Assistido']['id'], array(), 'Confirma a exclusão deste item?'))."</td>";
			echo "</tr>";
		}
		echo "</table>";
	} else {
		echo "<p>Não há nenhum assistido cadastrado.</p>";
	}